<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <script type="text/javascript">
            function showProj() {
                window.open("./pubinfo/projList.jsf", "项目列表", "height=1024,width=800,toolbar=no,menubar=no,scrollbars=no");
            }
            function updateProjSelect(code, name) {
                document.getElementById('loanbill:projCode').value = code;
                document.getElementById('loanbill:projName').value = name;
            }

            function showDept() {
                window.open("./pubinfo/departmentList.jsf", "部门列表", "height=1024,width=800,toolbar=no,menubar=no,scrollbars=no");
            }
            function updateDept(code, name) {
                document.getElementById('loanbill:deptcode').value = code;
                document.getElementById('loanbill:deptname').value = name;
            }
            function showCostItem() {
                window.open("./page/pay/check/ecoList.jsf", "经济分类", "height=1024,width=800,toolbar=no,menubar=no,scrollbars=no");
            }
            function updateCostItemName(code, name) {
                document.getElementById('loanbill:costcode').value = code;
                document.getElementById('loanbill:costname').value = name;
            }
        </script>
        <style type="text/css">
            .inputstype{
                width: 100px !important;
            }
        </style>
    </h:head>
    <h:form id="loanbill">
        <rich:panel header="统计表" styleClass="content-hight">
            <rich:messages globalOnly="true"/>
            <rich:pickList value="#{audit.selected}" orderable="true" listWidth="165px" listHeight="100px">
                <f:selectItem itemLabel="经济分类" itemValue="eoc"/>
                <f:selectItem itemLabel="预算来源" itemValue="budgetsource"/>
                <f:selectItem itemLabel="支出渠道" itemValue="costtype"/>
                <f:selectItem itemLabel="支出类别" itemValue="costclass"/>
                <f:selectItem itemLabel="项目" itemValue="projcode"/>
                <f:selectItem itemLabel="部门" itemValue="deptcode"/>
            </rich:pickList>           
            <rich:collapsiblePanel  header="查询条件"  switchType="client">
                <h:panelGrid columns="4">
                    <h:outputLabel value="单据编号：" for="number" />
                    <h:inputText size="17" id="number" value="#{audit.qstat.number}" />
                    <h:outputText value="单据日期："/>
                    <h:panelGroup>
                        <rich:calendar value="#{audit.qstat.numDateStart}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"  inputClass="inputstype"/>
                        至
                        <rich:calendar value="#{audit.qstat.numDateEnd}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"  inputClass="inputstype"/>
                    </h:panelGroup>
                    <h:outputLabel value="出差事由：" for="affair" />
                    <h:inputText size="17" id="affair" value="#{audit.qstat.affair}" />
                    <h:outputLabel value="金额：" />
                    <h:panelGroup>
                        <h:inputText size="17" id="totalStart" value="#{audit.qstat.totalStart}"/>
                        - <h:inputText size="17" id="totalEnd" value="#{audit.qstat.totalEnd}"/>
                    </h:panelGroup>
                    <h:outputLabel value="预算项目：" for="projname" />
                    <h:inputText size="17" id="projName" value="#{audit.qstat.project.finName}"
                                 onclick="#{rich:component('projPanel')}.show();"/>
                    <h:outputLabel value="经手人：" for="cpsn_name" />
                    <h:inputText size="17" id="cpsn_name" value="#{audit.qstat.user.cpsn_number}" />
                    <h:outputLabel value="部门：" for="deptname" />
                    <h:inputText size="17" id="deptname" value="#{audit.qstat.dept.name}"
                                 onclick="#{rich:component('deptPanel')}.show()"/>
                    <h:outputLabel value="支出类别：" for="costClass" />
                    <h:selectOneMenu id="costClass" value="#{audit.qstat.costClass}"
                                     style=" width: 125px;">
                        <f:selectItem itemValue=" " itemLabel="---请 选 择---"/>
                        <f:selectItem itemValue="0" itemLabel="基本支出"/>
                        <f:selectItem itemValue="1" itemLabel="项目支出"/>
                    </h:selectOneMenu>
                    <h:outputLabel value="预算来源：" for="budgetSource" />
                    <h:inputText size="17" id="budgetSource" value="#{audit.qstat.budgetSource}" />
                    <h:outputLabel value="经济分类：" for="costname" />
                    <h:inputText size="17" id="costname" value="#{audit.qstat.costitem.name}"   onclick="showCostItem()"/>
                    <h:outputLabel value="支出渠道："  for="costType" />
                    <h:selectOneMenu  id="costType"  value="#{audit.qstat.costTypes.code}"
                                      style=" width: 125px;">
                        <f:selectItem itemValue=" " itemLabel="---请 选 择---"/>
                        <f:selectItems value="#{class.selectItemList}" />
                    </h:selectOneMenu>
                    <h:outputLabel value="支付令：" for="paycode" />
                    <h:inputText size="17" id="paycode" value="#{audit.qstat.paycode}" />
                    <h:outputLabel value="核定金额：" />
                    <h:panelGroup>
                        <h:inputText size="17" id="checkaccountStart" value="#{audit.qstat.checkaccountStart}"/>
                        - <h:inputText size="17" id="checkaccountEnd" value="#{audit.qstat.checkaccountEnd}"/>
                    </h:panelGroup>
                    <h:outputText value="审核日期："/>
                    <h:panelGroup>
                        <rich:calendar value="#{audit.qstat.auditDateStart}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"  inputClass="inputstype"/>
                        至
                        <rich:calendar value="#{audit.qstat.auditDateEnd}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"  inputClass="inputstype"/>
                    </h:panelGroup>
                    <h:outputLabel value="支付方式：" for="payStyle" />
                    <h:inputText size="17" id="payStyle" value="#{audit.qstat.payStyle}" />
                    <h:outputLabel value="支票号：" for="ticketcode" />
                    <h:inputText size="17" id="ticketcode" value="#{audit.qstat.ticketcode}" />
                    <h:outputLabel value="支付金额：" />
                    <h:panelGroup>
                        <h:inputText size="17" id="payaccountStart" value="#{audit.qstat.payaccountStart}"/>
                        - <h:inputText size="17" id="payaccountEnd" value="#{audit.qstat.payaccountEnd}"/>
                    </h:panelGroup>
                    <h:outputText value="支付日期："/>
                    <h:panelGroup>
                        <rich:calendar value="#{audit.qstat.payDateStart}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"  inputClass="inputstype"/>
                        至
                        <rich:calendar value="#{audit.qstat.payDateEnd}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"  inputClass="inputstype"/>
                    </h:panelGroup>                       
                    <h:inputHidden id="costcode" value="#{audit.qstat.costitem.code}"/>
                </h:panelGrid>
            </rich:collapsiblePanel>                

            <h:commandButton value="查询" action="#{audit.checkandRep}" />
            <h:commandButton value="取消" action="#{audit.cancel}"/>
            <h:commandButton value="导出到Excel" action="#{audit.exportExcel}"  >
            </h:commandButton>
            <div style="width:100%;height: 300px;overflow:auto">
                <rich:dataTable id="editTable" value="#{audit.report}" var="explist"
                                rowClasses="list-row-odd,list-row-even" style=" width: 750px;"
                                headerClass="table-header" >
                    <f:facet name="header">
                        <rich:columnGroup>
                            <c:forEach items="#{audit.co}" var="co">
                                <rich:column>
                                    <h:outputText value="#{co}"/>
                                </rich:column>
                            </c:forEach>
                        </rich:columnGroup>
                    </f:facet>
                    <c:forEach items="#{audit.colIndex}" var="col">
                        <h:column>                         
                            <h:outputText value="#{explist[col]}">
                                <f:convertNumber type="number" pattern="#,##0.00"/>
                            </h:outputText>
                        </h:column>
                    </c:forEach>               
                </rich:dataTable>
            </div>
        </rich:panel>
    </h:form>
    <rich:popupPanel id="projPanel" autosized="true">
        <f:facet name="header">项目信息</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('projPanel')}.hide()">关闭</h:outputLink>
        </f:facet>
        <h:form id="projList">
            <rich:dataTable id="editTable" value="#{audit.finProjModel}" rows="10"  var="pro"
                            onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                            onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                            rowClasses="list-row-odd,list-row-even">
                <rich:column>
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="预算项目编码"/>
                        </h:panelGroup>
                    </f:facet>
                    <a4j:commandLink id="Projlinks" action="#{audit.selectProjForQuery}"
                                     onclick="#{rich:component('projPanel')}.hide();"
                                     render="projName" >
                        <h:outputText value="#{pro.finCode}"/>
                    </a4j:commandLink>
                </rich:column>

                <rich:column>
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="预算项目名称"/>
                        </h:panelGroup>
                    </f:facet>
                    <h:outputText value="#{pro.finName}"/>
                </rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="备注"/>
                        </h:panelGroup>
                    </f:facet>
                    <h:outputText value="#{pro.memo}"/>
                </rich:column>

                <f:facet name="footer">
                    <rich:dataScroller id="ds"></rich:dataScroller>
                </f:facet>
            </rich:dataTable>
        </h:form>
    </rich:popupPanel>
    <rich:popupPanel id="deptPanel" autosized="true">
        <f:facet name="header">
            <h:panelGroup>
                <h:outputText value="费用承担部门"></h:outputText>
            </h:panelGroup>
        </f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('deptPanel')}.hide()">关闭</h:outputLink>
        </f:facet>
        <h:form>
            <rich:panel>
                <h:panelGrid columns="2" width="100%" border="0" id="mainform">
                    <rich:tree value="#{departmentBean.rootNode}" var="idept"
                               selectionType="ajax" toggleType="client"
                               selectionChangeListener="#{audit.selecteDeptForQuery}"
                               style="width:300px" render="deptname">
                        <rich:treeNode>
                            <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                            <rich:componentControl target="deptPanel" operation="hide" event="click"/>
                        </rich:treeNode>
                    </rich:tree>
                </h:panelGrid>
            </rich:panel>
        </h:form>

        <f:facet name="footer">
            footer!
        </f:facet>

    </rich:popupPanel>
</ui:composition>


